<template>
	<view class="xvxcvdfgt">
		<swiper indicator-active-color="#fff" class="xzcxzcdftr" circular :indicator-dots="true" :autoplay="true"
			:interval="3000" :duration="1000">
			<swiper-item class="w100 h100" v-for="sd in ret.banner">
				<video class="w100 h100" :src="sd" controls v-if="czxcdfds(sd)"></video>
				<image v-else @tap="lltus(sd)" :src="sd" class="w100 h100 cz" mode="widthFix"></image>
			</swiper-item>


		</swiper>
		<view class="bgff pd pt20 pm20">
			<view class="fz34 z3 b pm20">
				{{ret.name}}
			</view>
			<view class="btm pt20">
				<view class=" display-flex">
					<view class="fz26 z9 display-flex flex-1">
						<text class=" vertical-center">
							综合薪资
						</text>
						<text class="ye fz40 b ml20">{{ret.payOverall}}</text>
					</view>
					<view class="fz24 z9 ">
						<view class="display-flex">
							<text class=" vertical-center">
								日领薪酬
							</text>
							<text class="ye fz40 b ml20">{{ret.pay}}</text>
						</view>
					</view>
				</view>
				<view class="z9 fz24 tr mt20">
					{{ret.jobDate}}
				</view>
				<view class="mt20">
					<text class="tag-label mr20" v-for="(item,index) in ret.tag">{{item}}</text>
				</view>
				<view class="btm mt30 display-flex pt20">
					<view class=" flex-1 display-flex">
						<image class="usdfgdgrt cz" :src="ret.sysUserImg"></image>
						<view class="ml20 vertical-center tl">
							<view class="">
								<view class="fz30">
									{{ret.sysUserName}}
								</view>
								<view class="z9 fz24 mt10">
									薪智直聘
								</view>
							</view>
						</view>
					</view>
					<view class=" vertical-center">
						<view class="">
							<text class="bkxczr" @tap="bohaosd">电话咨询</text>
							<text class="bkxczr ab ml20" @tap="fuzns(ret.sysUserWechat)">添加微信</text>
						</view>
					</view>
				</view>




			</view>

		</view>

		<view class="btm pt20 bgff pm20 pd">

			<view class="kxcxret">
				<view class="pd pt20 pm20 fz32 dfsdxcrt">
					薪资待遇
				</view>
				<view class=" display-flex dfcxrtre ">
					<view class="xcxzcfdsf z9 fz28 cen pt20 pm20">
						发薪日
					</view>
					<view class="fz28 z9 ml20 pt20 pm20">
						{{ret.payDate}}
					</view>
				</view>
				<view class=" display-flex dfcxrtre ">
					<view class="xcxzcfdsf z9 fz28 cen pt20 pm20">
						薪资详情
					</view>
					<view class="fz28 z9 ml20 pt20 pm20">
						{{ret.payContent}}
					</view>
				</view>
			</view>


			<view class="kxcxret mt20">
				<view class="pd pt20 pm20 fz32 dfsdxcrt">
					工作环境
				</view>
				<view class=" display-flex dfcxrtre ">
					<view class="xcxzcfdsf z9 fz28 cen pt20 pm20">
						班别
					</view>
					<view class="fz28 z9 ml20 pt20 pm20">
						{{ret.classContent}}
					</view>
				</view>
				<view class=" display-flex dfcxrtre ">
					<view class="xcxzcfdsf z9 fz28 cen pt20 pm20">
						着装
					</view>
					<view class="fz28 z9 ml20 pt20 pm20">
						{{ret.dressing}}
					</view>
				</view>
				<view class=" display-flex dfcxrtre ">
					<view class="xcxzcfdsf z9 fz28 cen pt20 pm20">
						站坐
					</view>
					<view class="fz28 z9 ml20 pt20 pm20">
						{{ret.posture}}
					</view>
				</view>
			</view>



			<view class="kxcxret mt20">
				<view class="pd pt20 pm20 fz32 dfsdxcrt">
					招聘要求
				</view>
				<view class=" display-flex dfcxrtre ">
					<view class="xcxzcfdsf z9 fz28 cen pt20 pm20">
						年龄
					</view>
					<view class="fz28 z9 ml20 pt20 pm20">
						{{ret.ageContent}}
					</view>
				</view>
				<view class=" display-flex dfcxrtre ">
					<view class="xcxzcfdsf z9 fz28 cen pt20 pm20">
						身份证
					</view>
					<view class="fz28 z9 ml20 pt20 pm20">
						{{ret.idCard}}
					</view>
				</view>
				<view class=" display-flex dfcxrtre ">
					<view class="xcxzcfdsf z9 fz28 cen pt20 pm20">
						纹身烟疤
					</view>
					<view class="fz28 z9 ml20 pt20 pm20">
						{{ret.tattoo}}
					</view>
				</view>
				<view class=" display-flex dfcxrtre ">
					<view class="xcxzcfdsf z9 fz28 cen pt20 pm20">
						英文字母
					</view>
					<view class="fz28 z9 ml20 pt20 pm20">
						{{ret.english}}
					</view>
				</view>
			</view>






			<view class="kxcxret mt20">
				<view class="pd pt20 pm20 fz32 dfsdxcrt">
					企业简介
				</view>
				<view class=" display-flex dfcxrtre ">

					<view class="fz28 z9 ml20 pt20 pm20">
						{{ret.companyContent}}
					</view>
				</view>


			</view>
			<view class="kxcxret mt20">
				<view class="pd pt20 pm20 fz32 dfsdxcrt">
					工作地点
				</view>
				<view class=" display-flex dfcxrtre ">
					<view class="xcxzcfdsf z9 fz28 cen pt20 pm20">
						厂址
					</view>

					<view class="fz28 z9 ml20 pt20 pm20 ls" @tap="jxzjnsd">
						{{ret.jobAddress}}
					</view>
				</view>


			</view>
		</view>
	</view>

	<view class="kmxzczxsfexe btm display-flex pd w100 pt10 pm10">
		<view class="cen" @tap="bohaosd">
			<view class="kxzczxerer vertical-center">
				<icon class="iconfont icon-dianhua cz fz40 z9"></icon>
			</view>
			<view class="z9 fz24 mt10">
				电话咨询
			</view>
		</view>
		<view class="cen ml30" @tap="jmxzcxsdf">
			<view class="kxzczxerer vertical-center">
				<icon class="iconfont icon-fenxiang cz fz40 z9"></icon>
			</view>
			<view class="z9 fz24 mt10">
				分享有礼
			</view>
		</view>
		<view class="cen ml30 pr">
			<view class="kxzczxerer vertical-center">
				<icon class="iconfont icon-kefu cz fz40 z9"></icon>
			</view>
			<view class="z9 fz24 mt10">
				在线客服
			</view>
			<button type="default" open-type="contact" class="xzcxcfesrewr"></button>
		</view>
		<view class="ml20 flex-1" @tap="baoming">
			<button type="primary" class="w100 fz36 h100 vertical-center">报名+</button>
		</view>
	</view>

	<view class="kmxcxzdrserx vertical-bottom" v-if="dfdvxcer">
		<view class="bgff w100">
			<view class=" cen pt20 pm20 fz32">
				分享到
			</view>
			<view class="btm pt40">
				<view class="kxczxcser display-flex">
					<view class=" flex-1 cen pr">
						<view class="">
							<icon class="iconfont icon-weixin ls xczxsdreet"></icon>
						</view>
						<view class=" z9 fz28 mt10">
							微信
						</view>
						<button type="default" open-type="share" class="xzcxcfesrewr"></button>
					</view>
					<view class=" flex-1 cen" @tap="sjnxf">
						<view class="">
							<icon class="iconfont icon-yingxiaogongju-shoujihaibao ye xczxsdreet"></icon>
						</view>
						<view class=" z9 fz28 mt10">
							生成海报
						</view>
					</view>
				</view>
			</view>
			<view class="btm mt40 pt20 pm20 fz26 z9 cen" @tap="dfdvxcer=false">
				取消分享
			</view>
		</view>
	</view>


	<view class="lkxzcxzcrer vertical-center" v-if="kjjxczx">
		<view class="pr">
			<view class=" tr fdsfxtretre">
				<icon class="iconfont icon-14CIRCLE fz60 cf" @tap="kjjxczx=false"></icon>
			</view>
			<image :src="fzxdd" class="xczxcrtexzewr"></image>
			<view class="mt20">
				<button type="primary" @tap="kmnxcz(fzxdd)">
					<icon class="iconfont icon-xiazai cz fz40"></icon>
					<text class="fz32 cz ml20">保存图片</text>
				</button>
			</view>
		</view>
	</view>


</template>
<script lang="ts" setup>
	import { ref } from "vue"
	import {
		onLoad,
		onPageScroll,
		onShow,
		onShareAppMessage
	} from "@dcloudio/uni-app";
		import { wxlogin } from "@/util/dxwchar.js"
	import { dxrequest, dxrequestht,VerifyTheLogin,zidianall } from "@/util/index.js"
	
	const kjjxczx = ref();
	const dfdvxcer = ref()
	const ret = ref({})
	const jobId = ref()
	const uset = ref({})
	const inviteUserId = ref() // 分享人的openid
	let userId = uni.getStorageSync("userId")
	let openid = uni.getStorageSync("openid")
	const fzxdd = ref()
	const kzzxcdfr = ref()
	const logov = ref()


	const lltus = (urls) => {
		uni.previewImage({
			urls: [urls]
		});
	}
	const bohaosd = () => {
		uni.makePhoneCall({
			phoneNumber: ret.value.sysUserPhone //仅为示例
		});
	}
	const fuzns = (data) => {
		uni.setClipboardData({
			data,
			success: function () {
				uni.showToast({
					title: "微信号已复制！"
				})
			},
			complete: (data) => {
				console.log(data)
			}
		});
	}
	const czxcdfds = (data) => {
		let jdd = false
		if (data.indexOf(".mp4") >= 0) {
			jdd = true
		}
		return jdd
	}
	const jxzjnsd = () => {
		uni.openLocation({
			latitude: ret.value.lat,
			longitude: ret.value.lng,
			name: ret.value.name,
			address: ret.value.jobAddress,
			success: function () {
				console.log('success');
			}
		});
	}
	const jmxzcxsdf = async () => {
		dfdvxcer.value = true
	}
	const baoming = async () => {
		const obj = {}
		obj.jobId = jobId.value
		obj.userId = userId
		if(inviteUserId.value!=userId){
			obj.inviteUserId = inviteUserId.value
		}
		const khnbxd = await dxrequest("/api/jobregist", obj, "post")
		if (khnbxd.code == 0) {
			uni.showToast({
				title: "报名成功！"
			})
		}
	}
	const sjnxf = async () => {
		const jmxczfd = await dxrequest("/api/job/inviteKey/" + ret.value.id)
		uni.showLoading({
			title: "生成中..."
		})
		const { data } = await dxrequestht('https://duxinggj.com/xzzp/payment/zhipupdataImg?openidxwertw=' + userId + "&Jobid=" + jmxczfd.data)
		let urlsd = `https://duxinggj-1251133427.cos.ap-guangzhou.myqcloud.com/case/%E8%96%AA%E6%99%BA%E7%9B%B4%E8%81%98/haibao.html?logo=${logov.value}&tag=小时工,正式工,学生工&companyName=薪智直聘&name=${ret.value.name}&payOverall=${ret.value.payOverall}&pay=${ret.value.pay}&jobAddress=${ret.value.jobAddress}&qccode=${data}`

		urlsd = encodeURIComponent(urlsd)

		const kxcxre = await dxrequestht("https://duxinggj.com/util/exportjpg?url=" + urlsd + "&pageWidth=375&pageHeight=780")
		fzxdd.value = kxcxre.data

		uni.hideLoading()
		dfdvxcer.value = false
		kjjxczx.value = true

	}
	onShareAppMessage(() => {
		return {
			title: '岗位详情',
			path: '/pages/index/jobDetails?inviteUserId=' + userId + "&id" + jobId.value
		}
	})
	const kmnxcz = (url) => {
		uni.showLoading({
			title: "下载中"
		})
		uni.downloadFile({
			url, //仅为示例，并非真实的资源
			success: (res) => {
				if (res.statusCode === 200) {
					uni.saveImageToPhotosAlbum({
						filePath: res.tempFilePath,
						success: function () {
							uni.hideLoading()
							uni.showToast({
								title: "保存成功！"
							})
						}
					});
				}
			},
			complete: (data) => {
				console.log(data)
			}
		});
	}

	const jnnxc = () => {
		uni.showToast({
			title: "请先实名认证",
			icon: "none"
		})
	}
	const initss = async (id, ty) => {
		uni.showLoading({
			title: "加载中"
		})
		let xcxdrt = null
		if (ty == 1) {
			xcxdrt = await dxrequest("/api/job/" + id)
		} else {
			xcxdrt = await dxrequest("/api/job/getByInviteKey/" + id)
		}
		xcxdrt.data.banner = xcxdrt.data.banner.split(",")
		try {
			xcxdrt.data.tag = xcxdrt.data.tag.split(",")
		} catch (e) {

		}
		jobId.value = xcxdrt.data.id
		uni.hideLoading()
		ret.value = xcxdrt.data
		uset.value = xcxdrt.data
	}
	onLoad(async (data) => {
		const logo = await zidianall("logo")
		logov.value = logo[0].dictValue
		if(!openid){
			const dxdfrt = await wxlogin()
			const xcxrty = await dxrequest("/api/user/" + dxdfrt.openid)
			uni.setStorageSync("openid",dxdfrt.openid)
			uni.setStorageSync("userId",xcxrty.data.id)
			openid = uni.getStorageSync("openid")
			userId = uni.getStorageSync("userId")
		}
		const scene = decodeURIComponent(data.scene)
		if (data.id) {
			inviteUserId.value = data.inviteUserId
			jobId.value = data.id
			initss(jobId.value, 1)
		} else {
			inviteUserId.value = scene.split(",")[0]
			jobId.value = scene.split(",")[1]
			if(jobId.value){
				initss(jobId.value, 2)
			}
		
		}


		if (inviteUserId.value) {
			uni.setStorageSync("inviteUserId", inviteUserId.value)
		}



	})

	const getid = async (code) => {
		const jkmxzc = await dxrequest("/api/job/getByInviteKey/" + code)
		console.log(jkmxzc)
	}
</script>

<style scoped>

</style>